{% extends "base.html" %}

{% load crispy_forms_tags i18n icons permissions translations %}

{% block breadcrumbs %}
  {% if path_object %}
    {% path_object_breadcrumbs path_object %}
    <li class="breadcrumb-item">
      <a href="{% url 'changes' path=path_object.get_url_path %}?{{ query_string }}">{% translate "Changes" %}</a>
    </li>
  {% else %}
    <li class="breadcrumb-item">
      <a href="{% url 'changes' %}?{{ query_string }}">{% translate "Changes" %}</a>
    </li>
  {% endif %}

  <div class="btn-group float-end btn-group-settings" role="group">
    {% if debug %}
      {% if path_object %}
        <a href="{% url 'changes' path=path_object.get_url_path %}?{{ query_string }}&amp;digest=1"
           title="{% translate "View notification" %}"
           class="btn btn-link">{% icon "bell.svg" %}</a>
      {% else %}
        <a href="{% url 'changes' %}?{{ query_string }}&amp;digest=1"
           title="{% translate "View notification" %}"
           class="btn btn-link">{% icon "bell.svg" %}</a>
      {% endif %}
    {% endif %}
    {% perm 'change.download' path_object as user_can_download_changes %}
    {% if user_can_download_changes %}
      {% if path_object %}
        <a href="{% url 'changes-csv' path=path_object.get_url_path %}?{{ query_string }}"
           title="{% translate "Download latest changes as CSV" %}"
           class="btn btn-link">{% icon "download.svg" %}</a>
      {% else %}
        <a href="{% url 'changes-csv' %}?{{ query_string }}"
           title="{% translate "Download latest changes as CSV" %}"
           class="btn btn-link">{% icon "download.svg" %}</a>
      {% endif %}
    {% endif %}
    <a href="{{ changes_rss }}"
       title="{% translate "Follow using RSS" %}"
       class="btn btn-link">{% icon "rss.svg" %}</a>
  </div>
{% endblock breadcrumbs %}

{% block content %}
  {% if form.is_valid %}
    {% include "paginator.html" %}
    {% format_last_changes_content last_changes=object_list user=user %}
    {% include "paginator.html" %}
  {% endif %}

  <form method="get">
    <div class="card">
      <div class="card-header">
        <h4 class="card-title">{% translate "Search" %}</h4>
      </div>
      <div class="card-body">{{ form|crispy }}</div>
      <div class="card-footer">
        <input type="submit" value="{% translate "Search" %}" class="btn btn-primary" />
      </div>
    </div>
  </form>

{% endblock content %}
